package ma.co.ba.BusinessApplications.business.interventions.impl;

import java.util.List;

import ma.co.ba.BusinessApplications.business.interventions.InterventionBusiness;
import ma.co.ba.BusinessApplications.dao.commons.DAOServices;
import ma.co.ba.BusinessApplications.model.Intervention;
import ma.co.ba.BusinessApplications.model.Utilisateur;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("interventionBusiness")
public class InterventionBusinessImpl implements InterventionBusiness {

	@Autowired
	DAOServices daoServices;

	public Intervention getInterventionById(int id) {
		return (Intervention) daoServices
				.getEntityById2(Intervention.class, id);
	}

	public List<Intervention> getAllInterventions() {
		return (List<Intervention>) daoServices.getEntities(Intervention.class);
	}

	public List<Intervention> getInterventionsByUsername(String username) {
		Utilisateur user = (Utilisateur) daoServices
				.getUniqueEntitiyByProperty(Utilisateur.class, "nomComplet",
						username);
		System.out.println(user.getInterventions());
		
		return user.getInterventions();
	}
}